package com.ruoyi.web.controller.wbgame;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wbgame.domain.WbGamePublish;
import com.ruoyi.wbgame.service.IWbGamePublishService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 游戏发布Controller
 * 
 * @author guguofu
 * @date 2021-04-16
 */
@Controller
@RequestMapping("/wbgame/gamePublish")
public class WbGamePublishController extends BaseController
{
    private String prefix = "wbgame/gamePublish";

    @Autowired
    private IWbGamePublishService wbGamePublishService;

    @RequiresPermissions("wbgame:gamePublish:view")
    @GetMapping()
    public String gamePublish()
    {
        return prefix + "/gamePublish";
    }

    /**
     * 查询游戏发布列表
     */
    @RequiresPermissions("wbgame:gamePublish:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WbGamePublish wbGamePublish)
    {
        startPage();
        List<WbGamePublish> list = wbGamePublishService.selectWbGamePublishList(wbGamePublish);
        return getDataTable(list);
    }

    /**
     * 导出游戏发布列表
     */
    @RequiresPermissions("wbgame:gamePublish:export")
    @Log(title = "游戏发布", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WbGamePublish wbGamePublish)
    {
        List<WbGamePublish> list = wbGamePublishService.selectWbGamePublishList(wbGamePublish);
        ExcelUtil<WbGamePublish> util = new ExcelUtil<WbGamePublish>(WbGamePublish.class);
        return util.exportExcel(list, "gamePublish");
    }

    /**
     * 新增游戏发布
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存游戏发布
     */
    @RequiresPermissions("wbgame:gamePublish:add")
    @Log(title = "游戏发布", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WbGamePublish wbGamePublish)
    {
        return toAjax(wbGamePublishService.insertWbGamePublish(wbGamePublish));
    }

    /**
     * 修改游戏发布
     */
    @GetMapping("/edit/{teacherId}")
    public String edit(@PathVariable("teacherId") Long teacherId, ModelMap mmap)
    {
        WbGamePublish wbGamePublish = wbGamePublishService.selectWbGamePublishById(teacherId);
        mmap.put("wbGamePublish", wbGamePublish);
        return prefix + "/edit";
    }

    /**
     * 修改保存游戏发布
     */
    @RequiresPermissions("wbgame:gamePublish:edit")
    @Log(title = "游戏发布", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WbGamePublish wbGamePublish)
    {
        return toAjax(wbGamePublishService.updateWbGamePublish(wbGamePublish));
    }

    /**
     * 删除游戏发布
     */
    @RequiresPermissions("wbgame:gamePublish:remove")
    @Log(title = "游戏发布", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wbGamePublishService.deleteWbGamePublishByIds(ids));
    }
}
